package com.gitee.huanminabc.jlambda_sql.warapper;

import com.gitee.huanminabc.jcommon.reflect.BeanCopyUtil;
import com.gitee.huanminabc.jlambda_sql.SQL;
import com.gitee.huanminabc.jlambda_sql.SqlWrapper;

import java.io.Serializable;

public  abstract class AbstractBaseWrapper<T, Children extends AbstractBaseWrapper<T, Children>>   implements SqlWrapper,  Cloneable, Serializable {
    protected final Children typedThis = (Children) this; //对象本身
    protected SQL sql=new SQL();
    public AbstractBaseWrapper() {
    }
    public AbstractBaseWrapper( SQL sql) {
        this.sql.resetSQL(sql);//这样保证了sql的引用不变
    }
    public SQL SQL() {
        return sql;
    }

    @Override
    @SuppressWarnings("all")
    public Children clone() {
        return   BeanCopyUtil.deepCopy(typedThis);
    }


    @Override
    public String sql() {
        return SQL().getSql();
    }

    @Override
    public Object[] params() {
        return  SQL().getParams().toArray();
    }

}
